package woshiheima14;

public class TreeNode {
    //节点的权
    int value;
    //左二子
    TreeNode lNode;
    //右儿子
    TreeNode rNode;
   public TreeNode(int value){
    this.value=value;
   }

    public TreeNode getlNode() {
        return lNode;
    }

    public void setlNode(TreeNode lNode) {
        this.lNode = lNode;
    }

    public TreeNode getrNode() {
        return rNode;
    }

    public void setrNode(TreeNode rNode) {
        this.rNode = rNode;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public void frontShow() {
        //先遍历当前节点
        System.out.println(value);
        //左节点
        if (lNode!=null){
            lNode.frontShow();
        }
        //右节点
        if (rNode!=null){
            rNode.frontShow();
        }
    }

    public void midShow() {
        //左节点
        if (lNode!=null){
            lNode.frontShow();
        }
        //先遍历当前节点
        System.out.println(value);
        //右节点
        if (rNode!=null){
            rNode.frontShow();
        }
    }

    public void afterShow() {
        //左节点
        if (lNode!=null){
            lNode.frontShow();
        }
        //右节点
        if (rNode!=null){
            rNode.frontShow();
        }
        //先遍历当前节点
        System.out.println(value);
    }
}
